<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>eshop</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../../../mui/css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../../css/app.css" />
		<link rel="stylesheet" type="text/css" href="../../../mui/css/icons-extra.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">订单列表</h1>
</header>
<div class="mui-content" id="orders">
	
</div>
</body>
<script src="../../../mui/js/mui.min.js"></script>
<script src="../../../js/common.js"></script>
<script src="../../../js/ajax-common.js"></script>	
<script src="../../../js/jquery-2.1.1.min.js"></script>		
<script type="text/javascript" charset="utf-8">
	mui.init({
		swipeBack: true //启用右滑关闭功能
	});
	mui.ready(function(){
		var act=window.localStorage.act;
		var url;
		if(act=="a"){
			url="order/list/a";
		}else if(act=="p"){
			url="order/list/p";
		}else{
			url="order/list/g";
		}
		window.localStorage.act="b";
		var success = function(response) {
			var orders=response.orders;
			setOrders(orders);
		};
		ajaxFunc(url, success);
	});
	function setOrders(orders){
		var ordersHtml="";
		for(key in orders){
			ordersHtml=ordersHtml+setOrder(orders[key]);
		}
		$("#orders").html(ordersHtml);
	}
	function setOrder(order){
		var orderHtml="";
		var orderStatusHtml="";
		if(order.orderStatus==00){
			orderStatusHtml='<button class="mui-btn mui-btn-outlined">取消订单</button><button class="mui-btn mui-btn-warning">直接付款</button>';
		}else if(order.orderStatus==01){
			orderStatusHtml='<button class="mui-btn mui-btn-outlined">跟踪快递</button><button class="mui-btn mui-btn-warning">确认收货</button>';
		}else{
			orderStatusHtml='<button class="mui-btn mui-btn-warning">删除订单</button>';
		}
		var orderStartHtml='<div class="mui-content"><ul class="mui-table-view"><li class="mui-table-view-cell"><div class="mui-table"><div class="mui-table-cell mui-col-xs-6"><p>订单编号：'+
		order.orderNo+'</p></div><div class="mui-table-cell mui-col-xs-2 mui-text-right"><span class="mui-h5"><font color="#000000">'+
		order.orderStatus+'</font></span></div></div></li>';
		var orderEndHtml='<li class="mui-table-view-cell"><div class="mui-media-body"><p class="mui-text-right">订单总价：<font color="#FF0000">￥'+
		order.totalAmount+'元</font></p></div><br><div class="mui-table"><div class="mui-table-cell mui-col-xs-6 mui-text-right" id="operation">'+
		orderStatusHtml+'<button class="mui-btn mui-btn-outlined">查看详情</button></div></div></li></div>';
		var orderDetails=order.orderDetails;
		for(key in orderDetails){
				orderHtml=orderHtml+orderStartHtml+setOrderGoods(orderDetails[key])+orderEndHtml;
			}
		return orderHtml;
	}
	function setOrderGoods(orderDetail){
		var goodsHtml='<li class="mui-table-view-cell"><img class="order-image mui-pull-left" src="'+imageCxt+orderDetail.goodsImageUrl+'"><div class="mui-media-body"><div class="mui-table"><div class="mui-table-cell mui-col-xs-6"><textarea class="index-textarea" readonly="readonly">'+
		orderDetail.goodsName+'</textarea></div> <div class="mui-table-cell"><textarea class="textarea" readonly="readonly">￥'+orderDetail.price+'元</textarea><textarea class="textarea" readonly="readonly">x'+
		orderDetail.quantity+'</textarea></div></div></div></li>';
		return goodsHtml;
	}
	function orderDetail() {
		mui.openWindow({
			url: "orderDetail.html",
			id: "orderDetail",
			show: {
				aniShow: 'zoom-fade-out',
				duration: 300
			}
		});
	}
</script>

</html>